var year=2019;
var month=5;
document.querySelector("#nian").innerHTML=year;
document.querySelector("#yue").innerHTML=month;
function runNian(y){
    if(y % 400 === 0||(y % 4 === 0 && y % 100 !==0)){
        return true;

    }else{
        return false;
    }
}

var days=0;
for(var i=1980; i<year; i++){
    if(runNian(i)){
        days+=366;
    }else{
        days+=365;
    }
    console.log(i);
}
console.log(days);
for(var k=1;k<month;k++){
    switch(k){
        case 1:
            days+=31;
            break;
        case 2:
            if(runNian(i)){
                days+=29;
            }else{
                days+=28;
            }
            break;
        case 3:
            days+=31;
            break;
        case 4:
            days+=30;
            break;
        case 5:
            days+=31;
            break;
        case 6:
            days+=30;
            break;
        case 7:
            days+=31;
            break;
        case 8:
            days+=31;
            break;
        case 9:
            days+=30;
            break;
        case 10:
            days+=31;
            break;
        case 11:
            days+=30;
            break;
        case 12:
            days+=31;
            break;

    }
}
console.log(days);
var day=0;
switch(month){
    case 1:
        day+=31;
        break;
    case 2:
        if(runNian(year)){
            day+=29;
        }else{
            day+=28;
        }
        break;
    case 3:
        day += 31;
        break;
    case 4:
        day += 30;
        break;
    case 5:
        day += 31;
        break;
    case 6:
        day += 30;
        break;
    case 7:
        day += 31;
        break;
    case 8:
        day += 31;
        break;
    case 9:
        day += 30;
        break;
    case 10:
        day += 31;
        break;
    case 11:
        day += 30;
        break;
    case 12:
        day += 31;
        break;

}
var pre = 0;
if(month = 1){
    pre += 31;
}else{
    switch(month - 1){
        case 1:
            pre += 31;
            break;
        case 2:
            if(runNian(year)){
                pre += 29;
            }else{
                pre += 28;
            }
            break;
        case 3:
            pre += 31;
            break;
        case 4:
            pre += 30;
            break;
        case 5:
            pre += 31;
            break;
        case 6:
            pre += 30;
            break;
        case 7:
            pre +=31;
            break;
        case 8:
            pre += 31;
            break;
        case 9:
            pre += 30;
            break;
        case 10:
            pre += 31;
            break;
        case 11:
            pre += 30;
            break;
        case 12:
            pre += 31;
            break;

    }
}

var num = 42;
days += 2;
console.log(days);
var start = days % 7;

var nextDay=num-day-start;
console.log(nextDay);
var thisday=new Date().getDate();
var date1=document.querySelector("#date1");

if(start == 0){
    for(var j = pre - 7 + 1;j <= pre;j++){
        date1.innerHTML += "<span class='h'>"+ j +"</span>";
    }
}else{
    for(var n = pre - start + 1;n <= pre;n++){
        date1.innerHTML += "<span class='h'>"+n+"</span>";
    }
}
for(var b = 1;b <= day;b++){
    if(b == thisday){
        date1.innerHTML+="<span class='today'>"+ b +"</span>";
    }else{

        date1.innerHTML += "<span>"+ b +"</span>";
    }
}
if(start == 0){
    for(var c = 1;c <= num - 7 - day; c++){
        date1.innerHTML+="<span class='h'>"+c+"</span>";
    }
}else{
    for(var c = 1;c <= nextDay; c++){
        date1.innerHTML+="<span class='h'>"+c+"</span>";
    }
}



